import React from 'react'
import { ThemeContext } from '../theme-context'

interface ButtonMeta {
    changeThme: () => void
}

class Button extends React.Component<ButtonMeta> {
    render() {
        let props = this.props;
        // let context = this.context;
        return (
            <ThemeContext.Consumer>
                {
                    (theme) => {
                        console.log(theme, 'theme from button')
                        return (
                            <button style={{ background: theme.background, color: theme.foreground }} onClick={props.changeThme}>按钮主题</button>
                        )
                    }
                }
            </ThemeContext.Consumer>
        )
    }
}
Button.contextType = ThemeContext;

export default Button